import dash
import numpy as np
import pandas as pd
from dash import html
import feffery_antd_components as fac

demo_df = pd.DataFrame({
    '字段1': np.random.randint(2, 7, 100)
})

demo_df['按钮示例'] = (
    demo_df['字段1']
        .map(lambda x: [{
        'content': f'按钮{i}',
        'type': 'primary'
    } for i in range(x)])
)

app = dash.Dash(__name__)

app.layout = html.Div(
    [
        fac.AntdTable(
            data=demo_df.to_dict('records'),
            columns=[
                {
                    'title': '字段1',
                    'dataIndex': '字段1',
                    'width': 200
                },
                {
                    'title': '按钮示例',
                    'dataIndex': '按钮示例',
                    'renderOptions': {'renderType': 'button'}
                }
            ],
            bordered=True
        )
    ],
    style={
        'padding': '50px 100px'
    }
)

if __name__ == '__main__':
    app.run_server(debug=True)
